//
//  ThirdShareUtil.m
//  ScholarsBridge
//
//  Created by guggle on 17/2/14.
//  Copyright © 2017年 mingthink. All rights reserved.
//

#import "ThirdShareUtil.h"
#import <ShareSDK/ShareSDK.h>
#import <ShareSDKConnector/ShareSDKConnector.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/QQApiInterface.h>
//#import "WeiboSDK.h"

static NSString *wxAppID = @"wx692d29d66e14e9bd";//正式：wx692d29d66e14e9bd,测试：wx9f437878a1fbeb53
static NSString *wxAppSecret = @"d5cebe77dabfe7c67f44f58e378454a4";//正式：d5cebe77dabfe7c67f44f58e378454a4,测试：04dd0400dae7df73ce8333ebba8916a5
static NSString *qqAppID = @"1105745451";
static NSString *qqAppKey = @"vAR6cBDt8hhAC2LR";

@implementation ThirdShareUtil

/**
 第三方分享和登录初始化
 */
+ (void)initSharePlatform {
    int mode=[HostUtil sharedInstance].mode;
    if (mode==0||mode==1) {
        wxAppID=@"wx9f437878a1fbeb53";
        wxAppSecret=@"04dd0400dae7df73ce8333ebba8916a5";
    }else{
        wxAppID=@"wx692d29d66e14e9bd";
        wxAppSecret=@"d5cebe77dabfe7c67f44f58e378454a4";
    }
    /**
     *  设置ShareSDK的appKey，如果尚未在ShareSDK官网注册过App，请移步到http://mob.com/login 登录后台进行应用注册
     *  在将生成的AppKey传入到此方法中。
     *  方法中的第二个第三个参数为需要连接社交平台SDK时触发，
     *  在此事件中写入连接代码。第四个参数则为配置本地社交平台时触发，根据返回的平台类型来配置平台信息。
     *  如果您使用的时服务端托管平台信息时，第二、四项参数可以传入nil，第三项参数则根据服务端托管平台来决定要连接的社交SDK。
     */
    [ShareSDK registerApp:@"1b465a8893800"
          activePlatforms:@[
                            @(SSDKPlatformTypeSinaWeibo),
                            @(SSDKPlatformTypeSMS),
                            @(SSDKPlatformTypeCopy),
                            @(SSDKPlatformTypeWechat),
                            @(SSDKPlatformTypeQQ),]
                 onImport:^(SSDKPlatformType platformType)
     {
         switch (platformType)
         {
             case SSDKPlatformTypeWechat:
                 [ShareSDKConnector connectWeChat:[WXApi class]];
                 break;
             case SSDKPlatformTypeQQ:
                 [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];
                 break;
//             case SSDKPlatformTypeSinaWeibo:
//                 [ShareSDKConnector connectWeibo:[WeiboSDK class]];
//                 break;
             default:
                 break;
         }
     }
          onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
     {
         
         switch (platformType)
         {
             case SSDKPlatformTypeSinaWeibo:
                 //设置新浪微博应用信息,其中authType设置为使用SSO＋Web形式授权
                 [appInfo SSDKSetupSinaWeiboByAppKey:@"568898243"
                                           appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
                                         redirectUri:@"http://www.sharesdk.cn"
                                            authType:SSDKAuthTypeBoth];
                 break;
             case SSDKPlatformTypeWechat:
                 [appInfo SSDKSetupWeChatByAppId:wxAppID
                                       appSecret:wxAppSecret];
                 break;
             case SSDKPlatformTypeQQ:
                 [appInfo SSDKSetupQQByAppId:qqAppID
                                      appKey:qqAppKey
                                    authType:SSDKAuthTypeBoth];
                 break;
             default:
                 break;
         }
     }];
}

+(NSString *)wxAppID{
    int mode=[HostUtil sharedInstance].mode;
    if (mode==0||mode==1) {
        wxAppID=@"wx9f437878a1fbeb53";
    }else{
        wxAppID=@"wx692d29d66e14e9bd";
    }
    return wxAppID;
}

+(NSString *)wxAppSecret{
    int mode=[HostUtil sharedInstance].mode;
    if (mode==0||mode==1) {
        wxAppSecret=@"04dd0400dae7df73ce8333ebba8916a5";
    }else{
        wxAppSecret=@"d5cebe77dabfe7c67f44f58e378454a4";
    }
    return wxAppSecret;
}

@end
